from typing import List


class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        res = ''
        if not strs:
            return ''
        i = 0
        while True:
            if i >= len(strs[0]):
                return res
            c = strs[0][i]
            for s in strs:
                if i >= len(s) or s[i] != c:
                    return res
            i += 1
            res += c
        return res